home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 5 / Example 5.6 / functions.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-01-30  |  471 b   |  16 lines

  1. #include "functions.h"
  2.  
  3. INTPOINT GetScreenPos(D3DXVECTOR3 pos, IDirect3DDevice9* Device)
  4. {
  5.     D3DXVECTOR3 screenPos;
  6.     D3DVIEWPORT9 Viewport;
  7.     D3DXMATRIX Projection, View, World;
  8.  
  9.     Device->GetViewport(&Viewport);
  10.     Device->GetTransform(D3DTS_VIEW, &View);
  11.     Device->GetTransform(D3DTS_PROJECTION, &Projection);
  12.     D3DXMatrixIdentity(&World);
  13.     D3DXVec3Project(&screenPos, &pos, &Viewport, &Projection, &View, &World);
  14.  
  15.     return INTPOINT(screenPos.x, screenPos.y);
  16. }